<?php
/**
 * feed中，将3rd_info还原为一个简化过的标准USER信息
 * @param string|array $data
 * @param int $source
 */
function decode_3rd_info_feed($data_3rd, $source = 0){
	$result = array(
		'id' => 0,
		'nickname' => '匿名',
		'face_xl' => '',
		'face_m' => '',
		'face_s' => '',
		'face_xs' => '',
		'location' => '',
		'3rd_info' => array(),
	);
	
	//decode 3rd
	if(!is_array($data_3rd) && !empty($data_3rd)){
		$data_3rd = json_decode($data_3rd, true);
		if(!is_array($data_3rd)){
			$data_3rd = array();
		}
	}else{
		$data_3rd = array();
	}
	
	if(empty($data_3rd)){
		return $result;
	}
	
	$result['3rd_info'] = $data_3rd;
	if(isset($data_3rd['screen_name'])){
		$result['nickname'] = $data_3rd['screen_name'];
	}
	$result['face_m'] = isset($data_3rd['profile_image_url']) ? $data_3rd['profile_image_url'] : '';
	if(2 == $source){
		$sina_uid = isset($data_3rd['uid']) ? $data_3rd['uid'] : 0;
		$mid_sina_urlprefix = '/'.$sina_uid.'/50/';
		$result['face_xl'] = strtr($result['face_m'], array($mid_sina_urlprefix => '/'.$sina_uid.'/180/'));
		$result['face_s'] = $result['face_xs'] = strtr($result['face_m'], array($mid_sina_urlprefix => '/'.$sina_uid.'/30/'));
	}else{
		$result['face_xl'] = $result['face_s'] = $result['face_xs'] = $result['face_m'];
	}
	
	return $result;
	
}